﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;

using ESRI.ArcGIS.Geodatabase;
using PlanningGIS.Win.Controls;
using PlanningGIS.Engine.Controls;

namespace PlanningGIS.DataCheck.form
{
    public partial class FrmArteryCheck : Office2007Form
    {
        private IMap pMap;
        private string lyrnameln;
        private string fcodeField;
        private string nameField;
        private IGeometry extent;

        public string LyrNameLn
        {
            get { return lyrnameln; }
        }


        public string FcodeField
        {
            get { return fcodeField; }
        }

        public string NameField
        {
            get { return nameField; }
        }

        public IGeometry Extent
        {
            get { return extent; }
        }

        public FrmArteryCheck(IMap value)
        {
            InitializeComponent();
            pMap = value;
        }

        private void FrmArteryCheck_Load(object sender, EventArgs e)
        {
            if (pMap == null)
            {
                MsgHelper.ShowInfomationMsgbox("当前系统没有可用的地图！");
                DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            LayersComboBox.FillFeatLyrName2cbo(this.cboLyrLn, pMap, esriGeometryType.esriGeometryPolyline, esriFeatureType.esriFTSimple, false, true);
            if (cboLyrLn.Items.Count > 0) cboLyrLn.SelectedIndex = 0;

            foreach (object obj in cboLyrLn.Items)
            {
                if (obj.ToString().ToUpper().Contains("TRA_NET_LN") || obj.ToString().Contains("路网线"))
                {
                    cboLyrLn.Text = obj.ToString();
                    break;
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cboLyrLn.Text == "")
            {
                MsgHelper.ShowInfomationMsgbox("请选择交通线层！");
                return;
            }

            if (txtFcode.Text == "")
            {
                MsgHelper.ShowInfomationMsgbox("请设置分类代码字段！");
                return;
            }

            if (txtName.Text == "")
            {
                MsgHelper.ShowInfomationMsgbox("请设置名称字段！");
                return;
            }

            lyrnameln = cboLyrLn.Text;
            fcodeField = txtFcode.Text;
            nameField = txtName.Text;

            extent = null;

            DialogResult = DialogResult.OK;

            this.Close();
        }
    }
}
